package com.qf.controller;


import com.qf.pojo.BaseResult;
import com.qf.pojo.City;
import com.qf.pojo.GbCity;
import com.qf.serivce.CityService;
;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/city")
@RestController
public class CityController {

    @Autowired
    CityService cityService;

    @RequestMapping("/findCityByPid")
    public BaseResult findCityByPid(@Param("pid") Integer pid) {
        List<City> citylist=cityService.findCityByPid(pid);
        BaseResult baseResult = new BaseResult();
        System.out.println(baseResult);
        if(citylist!=null){
            baseResult.setCode(1);
            baseResult.setInfo(citylist);
        }else{
            baseResult.setCode(0);
        }
        return baseResult;
    }

    @RequestMapping("/citys.do")
    public BaseResult GbCity(@Param("getid") Integer getid, @Param("backid") Integer backid){

        City getcity=cityService.GbCity(getid);
        City backcity = cityService.GbCity(backid);
        GbCity gbCity = new GbCity(getcity,backcity);
        BaseResult baseResult = new BaseResult();
        baseResult.setCode(1);
        baseResult.setInfo(gbCity);
        return baseResult;
    }
}


